package com.leyou.page.web;

import com.leyou.page.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 *
 * @author: wangzibeng
 * Date: 2019/5/10 0010
 * Time: 17:04
 */

@Controller
public class PageController {
    @Autowired
    private PageService pageService;

    @GetMapping("/item/{id}.html")
    public String toItemPage(Model model, @PathVariable("id") Long id) {
        //查询数据模型
        Map<String, Object> goods = pageService.loadGoodsById(id);
        model.addAllAttributes(goods);
        return "item";
    }
}
